<!--添加广告-->
{include file="public:header" /}
<!--图片水印设置-->
<form id="info_form" action="{:url('Poster/editDo')}" method="post">
    <div class="pad_lr_10">
        <div class="col_tab">
            <ul class="J_tabs tab_but cu_li">
                <li class="current">编辑广告</li>
            </ul>
            <div class="J_panes">
                <div class="content_list pad_10">
                    <table width="100%" cellpadding="2" cellspacing="1" class="table_form">
                        <tr>
                            <th width="80">所属城市 :</th>
                            <td>
                                <select class="J_city_select mr10" data-pid="0" data-uri="{:url('City/ajaxGetchilds')}" data-selected="{$info.city}"></select>
                                <input type="hidden" name="city" id="J_city_id" value="" />
                            </td>
                        </tr>
                        <tr>
                            <th width="80">广告标题 :</th>
                            <td><input type="text" name="name" id="name" value="{$info.name}" class="input-text" size="40"></td>
                        </tr>
                        <tr>
                            <th>广告类型 :</th>
                            <td>
                                <select name="type" id="type">
                                    {volist name="space_type" id="val"}
                                    <option value="{$key}" {if condition="$info['type'] eq $key"}selected{/if}>{$val}</option>
                                    {/volist}
                                </select>
                                <span style="color:#f60;">{$space_info.name}</span> {$space_info.width}*{$space_info.height} [{$space_info.type}]</td>
                        </tr>

                        <tr>
                            <th>有效时间 :</th>
                            <td>
                                <input type="text" name="startdate" id="startdate" onclick="myCalendar('startdate');" readonly class="date" size="20" value="{:date('Y-m-d H:i:s',$info['startdate'])}">
                                --
                                <input type="text" name="enddate" id="enddate" onclick="myCalendar();" class="date" size="20" value="{:date('Y-m-d H:i:s',$info['enddate'])}">
                            </td>
                        </tr>
                        {if condition="$space_info->getData('type') eq 'banner'"}
                        <tr>
                            <th>链接地址 : </th>
                            <td><input type="text" class="input-text" name="setting[linkurl]" value="{present name="info['setting']['linkurl']"}{$info.setting.linkurl}{/present}" size="30"></td>
                        </tr>
                        <tr>
                            <th>提示文字 : </th>
                            <td><input type="text" class="input-text" name="setting[alt]" value="{present name="info['setting']['alt']"}{$info.setting.alt}{/present}" size="30"></td>
                        </tr>
                        <tr>
                            <th>选择文件 : </th>
                            <td>
                                <input type="text" name="setting[fileurl]" id="J_img" class="input-text fl mr10" value="{present name="info['setting']['fileurl']"}{$info.setting.fileurl}{/present}" size="40"/>
                                &nbsp;&nbsp; <div id="J_upload_img" class="btn btn_submit" onclick="ajaxUpload('J_upload_img','J_img');"><span>上传</span></div>
                            </td>
                        </tr>
                        {/if}
                        {if condition="$space_info->getData('type') eq 'couplet'"}
                        <tr>
                            <th>左侧链接地址 : </th>
                            <td><input type="text" class="input-text" name="setting[left][linkurl]" value="{present name="info['setting']['left']['linkurl']"}{$info.setting.left.linkurl}{/present}" size="30"></td>
                        </tr>
                        <tr>
                            <th>左侧提示文字 : </th>
                            <td><input type="text" class="input-text" name="setting[left][alt]" value="{present name="info['setting']['left']['alt']"}{$info.setting.left.alt}{/present}" size="30"></td>
                        </tr>
                        <tr>
                            <th>左侧文件 : </th>
                            <td>
                                <input type="text" name="setting[left][fileurl]" id="J_left_img" class="input-text fl mr10" value="{present name="info['setting']['left']['fileurl']"}{$info.setting.left.fileurl}{/present}" size="40"/>
                                &nbsp;&nbsp; <div id="J_left_upload_img" class="btn btn_submit" onclick="ajaxUpload('J_left_upload_img','J_left_img');"><span>上传</span></div>
                            </td>
                        </tr>
                        <tr>
                            <th>右侧链接地址 : </th>
                            <td><input type="text" class="input-text" name="setting[right][linkurl]" value="{present name="info['setting']['right']['linkurl']"}{$info.setting.right.linkurl}{/present}" size="30"></td>
                        </tr>
                        <tr>
                            <th>右侧提示文字 : </th>
                            <td><input type="text" class="input-text" name="setting[right][alt]" value="{present name="info['setting']['right']['alt']"}{$info.setting.right.alt}{/present}" size="30"></td>
                        </tr>
                        <tr>
                            <th>右侧文件 : </th>
                            <td>
                                <input type="text" name="setting[right][fileurl]" id="J_right_img" class="input-text fl mr10" value="{present name="info['setting']['right']['fileurl']"}{$info.setting.right.fileurl}{/present}" size="40"/>
                                &nbsp;&nbsp; <div id="J_right_upload_img" class="btn btn_submit" onclick="ajaxUpload('J_right_upload_img','J_right_img');"><span>上传</span></div>
                            </td>
                        </tr>
                        <input type="hidden" name="setting[paddleft]" value="{$space_info['setting']['paddleft']}">
                        <input type="hidden" name="setting[paddtop]" value="{$space_info['setting']['paddtop']}">
                        {/if}
                        {if condition="$space_info->getData('type') eq 'imagelist'"}
                        <tr>
                            <th>链接地址 : </th>
                            <td><input type="text" class="input-text" name="setting[linkurl]" value="{present name="info['setting']['linkurl']"}{$info.setting.linkurl}{/present}" size="30"></td>
                        </tr>
                        <tr>
                            <th>提示文字 : </th>
                            <td><input type="text" class="input-text" name="setting[alt]" value="{present name="info['setting']['alt']"}{$info.setting.alt}{/present}" size="30"></td>
                        </tr>
                        <tr>
                            <th>选择图片 : </th>
                            <td>
                                <input type="text" name="setting[fileurl]" id="J_list_img" class="input-text fl mr10" value="{present name="info['setting']['fileurl']"}{$info.setting.fileurl}{/present}" size="40"/>
                                &nbsp;&nbsp; <div id="J_list_upload_img" class="btn btn_submit" onclick="ajaxUpload('J_list_upload_img','J_list_img');"><span>上传</span></div>
                            </td>
                        </tr>
                        {/if}
                        {if condition="$space_info->getData('type') eq 'text'"}
                        <tr>
                            <th>链接地址 : </th>
                            <td><input type="text" class="input-text" name="setting[linkurl]" value="{present name="info['setting']['linkurl']"}{$info.setting.linkurl}{/present}" size="30"></td>
                        </tr>
                        <tr>
                            <th>文字内容 : </th>
                            <td><input type="text" class="input-text" name="setting[title]" value="{present name="info['setting']['title']"}{$info.setting.title}{/present}" size="30"></td>
                        </tr>
                        {/if}
                        {if condition="$space_info->getData('type') eq 'code'"}
                        <tr>
                            <th>代码内容 : </th>
                            <td><textarea name="setting[code]" style="width:400px;height:100px;">{present name="info['setting']['code']"}{$info.setting.code}{/present}</textarea></td>
                        </tr>
                        {/if}
                        <tr>
                            <th>状态 :</th>
                            <td>
                                <label><input type="radio" name="status" value="1" {if condition="$info['status'] eq 1"}checked{/if}> 启用</label>&nbsp;&nbsp;
                                <label><input type="radio" name="status" value="0" {if condition="$info['status'] eq 0"}checked{/if}> 禁用</label>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <input type="hidden" name="spaceid" value="{$space_info.id}">
            <input type="hidden" name="id" value="{$info.id}">
            <input type="hidden" name="setting[height]" value="{$space_info.height}">
            <input type="hidden" name="setting[width]" value="{$space_info.width}">
            <input type="hidden" name="setting[space_type]" value="{$space_info->getData('type')}">
            <div class="mt10">
                <input type="submit" value="提交" id="dosubmit" name="" class="btn btn_submit" style="margin:0 0 0 100px;">
                <a id="button" href="{:url('Poster/index',['space_id'=>$space_info['id']])}" class="btn" style="height:20px;">返回列表</a>
                <br /><br /><br /></div>
        </div>
    </div>
</form>
{include file="public:footer" /}
<script src="__PUBLIC__/js/calendar/WdatePicker.js" charset="utf-8"></script>
<script src="__PUBLIC__/js/plugins/fileuploader.js"></script>
<script>
    $('.J_city_select').cate_select({field : 'J_city_id',id : 'J_city_select','level':1});
    function myCalendar(id){
        WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',el:id});
    }
    $(function(){
        $.formValidator.initConfig({formid:"info_form",autotip:true});
        $("#name").formValidator({onshow:"请填写广告名称",onfocus:"请填写广告名称"}).inputValidator({min:1,onerror:"请填写广告名称"}).defaultPassed();
    });
    function ajaxUpload(btn,input){
        //上传图片

        var img_uploader = new qq.FileUploaderBasic({
            allowedExtensions: ['jpg','gif','jpeg','png','swf'],
            button: document.getElementById(btn),
            multiple: false,
            action: "{:url('Poster/ajaxUploadImg')}",
            inputName: 'img',
            forceMultipart: true, //用$_FILES

            showMessage: function(message){
                $.yingloujie.tip({content:message, icon:'error'});
            },
            onSubmit: function(id, fileName){
                $('#'+btn).addClass('btn_disabled').find('span').text('上传中，请稍候...');
            },
            onComplete: function(id, fileName, result){
                $('#'+btn).removeClass('btn_disabled').find('span').text('上传');
                if(result.status == '1'){
                    $('#'+input).val(result.data);
                } else {
                    $.yingloujie.tip({content:result.msg, icon:'error'});
                }
            }
        });
    }
</script>
</body>
</html>

